// createRouter 可执行的函数 产出一个router路由实例对象  new VueRouter
// createWebHashHistory  可执行的函数  产出hash模式的路由配置对象

import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout'
import Home from '@/views/Home'
import Category from '@/views/Category'
import SubCategory from '@/views/Category/Sub'
import GoodDetail from '@/views/Goods'
import Login from '@/views/Login'
import Callback from '@/views/Login/Callback.vue'
import Cart from '@/views/Cart'
import Play from '@/views/Playground'

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '/',
        component: Home
      },
      {
        path: '/category/:id',
        component: Category
      },
      {
        path: '/subCategory/:id',
        component: SubCategory
      },
      {
        path: '/good/:id',
        component: GoodDetail
      },
      {
        path: '/cart',
        component: Cart
      }
    ]
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/play',
    component: Play
  },
  {
    path: '/login/callback',
    component: Callback
  }
  // {
  //   path: '/',
  //   name: 'Home',
  //   component: Home
  // },
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

// createRouter创建一个路由实例对象
// createWebHashHistory() 执行返回值交给history配置项
const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
